﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace A2.ERP.IDAL
{
    /// <summary>
    /// 基接口（完成数据库访问接口层公共方法的定义），让IUserInfoDal继承

    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IBaseDAL<T> where T : class,new()
    {
        //将一些公共的，重复的接口方法封装

        //查询
        IQueryable<T> LoadEntities(System.Linq.Expressions.Expression<Func<T, bool>> whereLambada);

        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">当前页的数量</param>
        /// <param name="totalCount">总数</param>
        /// <param name="wherelamdba">条件</param>
        /// <param name="orderby">排序条件</param>
        /// <param name="isAsc">排序方式</param>
        /// <returns></returns>
        IQueryable<T> LoadPageEntities<orderT>(int pageIndex, int pageSize, out int totalCount, Expression<Func<T, bool>> wherelamdba, Expression<Func<T, orderT>> orderby, bool isAsc);

        //删除
        bool DeleEntity(T entity);

        //修改
        bool UpdateEntity(T entity, params Expression<Func<T, object>>[] props);

        //添加
        T AddEntity(T entity);

        //存储过程（测试）
        List<T> Procedures<T>(string sql, params SqlParameter[] ps);
    }
}
